//use new CCC data for model estimation

import excel "$data/CCC/nationaldatabaseofchildcareprices.xlsx", clear firstrow
ren *, lower
save "$temp/bls_ccc_data", replace


use "$temp/bls_ccc_data", clear
ren state_abbreviation state
merge m:1 state using "$data/Crosswalks/state_fips_crosswalk", keep(match) nogen

keep county_fip studyyear mcinfant mctoddler mcpreschool mfccinfant mfcctoddler mfccpreschool statefips

//tweak prices
ds county study statefips, not
foreach var in `r(varlist)'{
	replace `var' = `var' * 52 // yearly
	replace `var' = `var' / 2000 //normalize
}
ren study year
keep if year<=2016 //reflecting PSID
collapse (first) statefips (mean) mc*, by(county_fip) //collapse prices over time

//now let's merge on some population measures and division codes
ren statefips stfips
merge m:1 stfips using "$data/Crosswalks/state_div_crosswalk", keep(match) nogen


//now get population measures
preserve
import excel using "$data/Crosswalks/cz00_eqv_v1.xls", firstrow clear
ren *, lower
keep fips countypop
ren countypop countypop
destring fips, replace
save "$temp/county_pops", replace
restore

preserve
ren county fips
merge m:1 fips using "$temp/county_pops", keep(match) nogen
egen price_mean = rowmean(mc*)
collapse (mean) price_mean [fw=countypop], by(stfips)
save "$temp/st_ccc_new", replace
restore






ren county fips
merge m:1 fips using "$temp/county_pops", keep(match) nogen
egen price_mean = rowmean(mc*)
collapse (mean) price_mean [fw=countypop], by(div)
ren div div
save "$temp/div_ccc_new", replace










//end of dofile